#@head() #@header()
<title>客户列表</title>
#@aside("user")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<style>
	.box-body{padding:5px !important}
</style>
<div class="content-wrapper">
	<section class="content">
	<div class="nav-tabs-custom">
	#@usersmenu("withdraw")
		<div class="tab-content">
		  <div class="tab-pane active" id="tab_1">
				<div class="box-body">
             
				<label style="float:left;margin-top:8px;margin-left:10px;">用户名：</label>
                <input id="mobile3" type="text" style="width:120px;float:left" class="form-control" placeholder="">
				<label style="float:left;margin-top:8px;margin-left:5px;">真实姓名：</label>
				<input type="text" id="realname" style="width:120px;float:left" class="form-control" placeholder="" >
				<label style="float:left;margin-top:8px;margin-left:5px;">提现时间：</label>
				<input id="createTimeStart" style="width:120px;float:left" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text" class="form-control" placeholder="">
				<label style="float:left;margin-top:8px;">—</label>
                <input id="createTimeEnd" style="width:120px;float:left" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text" class="form-control" placeholder="">
				<label style="float:left;margin-top:8px;margin-left:5px;">提现金额：</label>
				<input id="amountStart" style="width:120px;float:left" type="text" class="form-control" placeholder="">
				<label style="float:left;margin-top:8px;">—</label>
                <input id="amountEnd" style="width:120px;float:left" type="text" class="form-control" placeholder="">
				<label style="float:left;margin-top:8px;margin-left:5px;">状态：</label>
				<select id="status2" style="width:120px;float:left" class="form-control">
					<option value="">全部</option>
					<option value="success">已完成</option>
					<option value="process">进行中</option>
					<option value="failed">失败</option>
				</select>
				<div class="col-xs-1">
				  <button id="seachuser" type="button" class="btn btn-info btn-flat">搜索</button>
				</div>

            </div>
			<table class="table table-bordered" style="clear:both;width:40%;margin-left:10px;">
				<tbody>
				<tr>
				  <th>用户提现总人次：<span id="total_users"></span> 次（成功<span id="success_users"></span> 次）</th>
				  <th>用户提现总额：<span id="total_trade_amount"></span> 元</th>
				</tr>
			  </tbody>
			</table>
			<div class="box-body">
				<table  id="example1" class="table table-striped">
					<thead>
						<tr>
							<th>序号</th>
							<th>订单号</th>
							<th>用户名</th>
							<th>真实姓名</th>
							<th>提现金额（元）</th>
							<th>手续费（元）</th>
							<th>实际到账（元）</th>
							<th>提现时间</th>
							<th>状态</th>
							<th>备注</th>
						</tr>
					</thead>
					<tbody id="userlist">
						
					</tbody>
				</table>
				<div class="box-footer clearfix">
				  <ul class="pagination pagination-sm no-margin pull-right">
					<li id="userlist1"><a href="#">首页</a></li>
					<li id="userlist2"><a href="#">上一页</a></li>
					<li><a href="#">第<span id="userlist5"></span>页 共<span id="userlist6"></span>页</a></li>
					<li id="userlist3"><a href="#">下一页</a></li>
					<li id="userlist4"><a href="#">尾页</a></li>
				  </ul>
				</div>
			</div>
			</div>
		</div>
	</div>
	</section>
</div>
#@footer()
<script id="userlistall" type="text/x-jquery-tmpl">
	<tr>
		<td>${id}</td>
		<td>${code}</td>
		<td>${mobile}</td>
		<td>${real_name}</td>
		<td>￥${amount} </td>
		<td>￥${fee} </td>
		<td>￥${dzje} </td>
		<td>${create_time}</td>
		<td><span class="badge ${cla}">${status}</span></td>
		<td>${summary}</td>
	</tr>
</script>
<script>
var totalPage = 1;
var pageNumber = 1;
var mobile3="";
var createTimeStart="";
var createTimeEnd="";
var amountStart="";
var amountEnd="";
var status2="";
var realname = '';
 $(document).ready(function(){
	pageNumber = 1;
	$("#userlist").empty();
	userlist(pageNumber,mobile3,createTimeStart,createTimeEnd,amountStart,amountEnd,realname);
	$("#userlist5").html(pageNumber);
	
});
$("#userlist1").click(function(){
	$("#userlist").empty();
	pageNumber = 1;
	userlist(pageNumber,mobile3,createTimeStart,createTimeEnd,amountStart,amountEnd,realname);
	$("#userlist5").html(pageNumber);
});
$("#userlist2").click(function(){
	if(pageNumber==1){
		alert("当前页是首页!");
	}else{
		$("#userlist").empty();
		pageNumber = pageNumber-1;
		userlist(pageNumber,mobile3,createTimeStart,createTimeEnd,amountStart,amountEnd,realname);
		$("#userlist5").html(pageNumber);
	}
});
$("#userlist3").click(function(){
	if(pageNumber==totalPage){
		alert("当前页是尾页!");
	}else{
	$("#userlist").empty();
		pageNumber = pageNumber +1;
		userlist(pageNumber,mobile3,createTimeStart,createTimeEnd,amountStart,amountEnd,realname);
		$("#userlist5").html(pageNumber);
	}
});
$("#userlist4").click(function(){
	$("#userlist").empty();
	pageNumber = totalPage;
	userlist(pageNumber,mobile3,createTimeStart,createTimeEnd,amountStart,amountEnd,realname);
	$("#userlist5").html(pageNumber);
});
$("#seachuser").click(function(){
	$("#userlist").empty();
	mobile3 = $("#mobile3").val();
	createTimeStart = $("#createTimeStart").val();
	createTimeEnd = $("#createTimeEnd").val();
	amountStart = $("#amountStart").val();
	amountEnd = $("#amountEnd").val();
	status2 = $("#status2").val();
	pageNumber = 1;
	realname = $("#realname").val();
	userlist(pageNumber,mobile3,createTimeStart,createTimeEnd,amountStart,amountEnd,realname);
	$("#userlist5").html(pageNumber);
});

function userlist(pageNumber,mobile3,createTimeStart,createTimeEnd,amountStart,amountEnd,realname){ 
	url = "#(path)/withdraw/list?token=#(session.token??)&page="+pageNumber+"&size=15&mobile="+mobile3+"&amountEnd="+amountEnd+"&amountStart="+amountStart+"&createTimeStart="+createTimeStart+"&createTimeEnd="+createTimeEnd+"&status="+status2+"&realName="+realname;
	$.getJSON(url, function(userli) {
		console.log(userli);
		totalPage = userli.data.page.totalPage;
		$("#userlist6").html(totalPage);
		$("#total_users").html(userli.data.total_count);
		$("#success_users").html(userli.data.success_count);
		$("#total_trade_amount").html(userli.data.total);
		$.each(userli.data.page.list, function(i, item){ 
			var status ="";
			item.amount = (item.amount + item.user_fee).toFixed(2);
			if(item.status == "success"){
				var dzje = item.real_amount;
			}else {
				var dzje =0;
			}
			if(item.status == "success"){
				status = "已完成";
				var cla="bg-green";
			}else if(item.status == "failed"){
				status = "失败";
				var cla="bg-red";
			}else if(item.status == "process"){
				status = "进行中";
				var cla="bg-yellow";
			}
			if($.isBlank(item.user_fee)){
				var fee = 0;
			}else {
				var fee = item.user_fee;
			}
			var userlist = {cla:cla,mobile:item.mobile,real_name:item.user.real_name,summary:item.summary,dzje:dzje,id:item.id,code:item.code,amount:item.amount,fee:fee,create_time:item.create_time,status:status};
			$("#userlistall").tmpl(userlist).appendTo('#userlist');
		});
	});	
}


</script> 


</body>
</html>

